package cn.fl.mcr.transform;


import cn.fl.mcr.vo.McrSideAgreementVO;
import cn.lionbridgecapital.loan.model.dto.McrSideAgreementDTO;
import cn.lionbridgecapital.loan.model.po.McrSideAgreement;
import cn.lionbridgecapital.loan.model.utils.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 协议签署表 转换器
 * @Description: 服务层与展现层转换类
 * @Description: 所有的PO只能在持久成和服务层使用
 * @Description: 所有的DTO只能在展现层和服务层使用
 * @Description: 在服务层中向下是DTO转PO,向上是PO转DTO
 */
public class McrSideAgreementTransform {


	/**
	 * DTO 转  VO
	 * @param dto McrSideAgreementDTO
	 * @return McrSideAgreementVO
	 */
	public static McrSideAgreementVO baseToVO(McrSideAgreementDTO dto) {
		McrSideAgreementVO vo = null;
		if (dto != null) {
			vo = new McrSideAgreementVO();
			vo.setId(dto.getId());
			vo.setCstId(dto.getCstId());//客户ID
			vo.setUsrId(dto.getUsrId());//用户ID
			vo.setContNo(dto.getContNo());//合同号
			vo.setLoanAmt(dto.getLoanAmt());//借款金额
			vo.setLoanDate(dto.getLoanDate());//借款时间
			vo.setIsSideCont(dto.getIsSideCont());//是否补充合同
			vo.setPkId(dto.getPkId());//外键Key
			vo.setSignType(dto.getSignType());//签署类型
			vo.setLoanContNo(dto.getLoanContNo());//小贷合同号
			vo.setLoanCapital(dto.getLoanCapital());//资方
			vo.setAttr1(dto.getAttr1());//扩展字段1
			vo.setAttr2(dto.getAttr2());//扩展字段2
			vo.setIsValid(dto.getIsValid());//是否有效
			vo.setIsDel(dto.getIsDel());//是否删除

			vo.setCrtTm(dto.getCrtTm());//创建时间
			vo.setCrtUsrId(dto.getCrtUsrId());//创建人
			vo.setMdfTm(dto.getMdfTm());//修改时间
			vo.setMdfUsrId(dto.getMdfUsrId());//修改人
		}
		return vo;
	}

	/**
	 * VO to DTO
	 * @param vo McrSideAgreementVO
	 * @return McrSideAgreementDTO
	 */
	public static McrSideAgreementDTO baseToDTO(McrSideAgreementVO vo) {
		McrSideAgreementDTO dto = null;
		if (vo != null) {
			dto = new McrSideAgreementDTO();
			dto.setId(vo.getId());
			dto.setCstId(vo.getCstId());//客户ID
			dto.setUsrId(vo.getUsrId());//用户ID
			dto.setContNo(vo.getContNo());//合同号
			dto.setLoanAmt(vo.getLoanAmt());//借款金额
			dto.setLoanDate(vo.getLoanDate());//借款时间
			dto.setIsSideCont(vo.getIsSideCont());//是否补充合同
			dto.setPkId(vo.getPkId());//外键Key
			dto.setSignType(vo.getSignType());//签署类型
			dto.setLoanContNo(vo.getLoanContNo());//小贷合同号
			dto.setLoanCapital(vo.getLoanCapital());//资方
			dto.setAttr1(vo.getAttr1());//扩展字段1
			dto.setAttr2(vo.getAttr2());//扩展字段2
			dto.setIsValid(vo.getIsValid());//是否有效
			dto.setIsDel(vo.getIsDel());//是否删除

			dto.setCrtTm(vo.getCrtTm());//创建时间
			dto.setCrtUsrId(vo.getCrtUsrId());//创建人
			dto.setMdfTm(vo.getMdfTm());//修改时间
			dto.setMdfUsrId(vo.getMdfUsrId());//修改人
		}
		return dto;
	}

	/**
	 * VO 转  DTO
	 * @param vo McrSideAgreementVO
	 * @return McrSideAgreementDTO
	 */
	public static McrSideAgreementDTO toDTO(McrSideAgreementVO vo) {
		//设置自定义扩展属性
		return baseToDTO(vo);
	}

	/**
	 * DTO 转  VO
	 * @param dto McrSideAgreementDTO
	 * @return McrSideAgreementVO
	 */
	public static McrSideAgreementVO toVO(McrSideAgreementDTO dto) {
		//设置自定义扩展属性
		return baseToVO(dto);
	}

	/**
	 * VO集合 转 DTO集合
	 * @param list List<McrSideAgreementVO>
	 * @return List<McrSideAgreementDTO>
	 */
	public static List<McrSideAgreementDTO> toDTOList(List<McrSideAgreementVO> list) {
		List<McrSideAgreementDTO>  dtoList = new ArrayList<>();
		if(CollectionUtils.isNotEmpty(list)){
			for (McrSideAgreementVO dto : list) {
				dtoList.add(toDTO(dto));
			}
		}
		return dtoList;
	}

	/**
	 *  DTO集合 转 VO集合
	 * @param list List<McrSideAgreementVO>
	 * @return List<McrSideAgreementDTO>
	 */
	public static List<McrSideAgreementVO> toVOList(List<McrSideAgreementDTO> list) {
		List<McrSideAgreementVO>  voList = new ArrayList<>();
		if(CollectionUtils.isNotEmpty(list)){
			for (McrSideAgreementDTO dto : list) {
				voList.add(toVO(dto));
			}
		}
		return voList;
	}
}
